package api

import (
	"github.com/gin-gonic/gin"
	jwt "github.com/golangblogs/gojwt"
	"rabbit/api/handler"
	"rabbit/consts"
)

func LoadRouter(r *gin.Engine) {

	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/register", handler.Register)
		}
		chat := api.Group("/chat")
		{
			chat.Use(jwt.JWTAuth(consts.JWT_SECRET_KEY))
			chat.GET("/ws", handler.Chat)
		}
		history := api.Group("/history")
		{
			history.Use(jwt.JWTAuth(consts.JWT_SECRET_KEY))
			history.POST("/listHistory", handler.ListHistory)
		}
		admin := api.Group("/admin")
		{
			//admin.Use(jwt.JWTAuth(consts.JWT_SECRET_KEY))
			admin.POST("/sendAdmin", handler.SendAdmin)
		}
	}
}
